package cn.lg.soar.message.feign;


import cn.lg.soar.core.annotations.ApiClient;
import cn.lg.soar.message.api.constant.ModuleConst;
import cn.lg.soar.message.api.model.WebSocketDTO;
import cn.lg.soar.message.api.service.ISseApi;
import cn.lg.soar.message.feign.fallback.SseApiFallbackFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@ConditionalOnMissingClass("cn.lg.soar.message.client.SseApiClient")
@ApiClient
@FeignClient(
        name= ModuleConst.MODULE_NAME,
        path= ModuleConst.CLIENT_PATH + "/sse",
        fallbackFactory= SseApiFallbackFactory.class,
        contextId = "SseApiFeign"
)
public interface SseApiFeign extends ISseApi {

    @PostMapping("broadcast")
    @Override
    Collection<Long> broadcast(@RequestParam String topic, @RequestBody String message);

    @PostMapping("sendMessage")
    @Override
    Collection<Long> sendMessage(@RequestParam String topic, @RequestBody WebSocketDTO dto);

}
